package com.wuliu.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wuliu.common.annotation.Log;
import com.wuliu.common.core.controller.BaseController;
import com.wuliu.common.core.domain.AjaxResult;
import com.wuliu.common.enums.BusinessType;
import com.wuliu.system.domain.TspTrack;
import com.wuliu.system.service.ITspTrackService;
import com.wuliu.common.utils.poi.ExcelUtil;
import com.wuliu.common.core.page.TableDataInfo;

/**
 * 路由Controller
 * 
 * @author realue
 * @date 2023-10-25
 */
@Api(tags = {"路由管理控制"})
@RestController
@RequestMapping("/order/track")
public class TspTrackController extends BaseController {
    @Resource
    private ITspTrackService tspTrackService;

    /**
     * 查询路由列表
     */
    @ApiOperation(value = "查询")
    @PreAuthorize("@ss.hasPermi('order:track:list')")
    @GetMapping("/list")
    public TableDataInfo list(TspTrack tspTrack) {
        startPage();
        List<TspTrack> list = tspTrackService.selectTspTrackList(tspTrack);
        return getDataTable(list);
    }

    /**
     * 导出路由列表
     */
    @ApiOperation(value = "导出")
    @PreAuthorize("@ss.hasPermi('order:track:export')")
    @Log(title = "路由", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TspTrack tspTrack) {
        List<TspTrack> list = tspTrackService.selectTspTrackList(tspTrack);
        ExcelUtil<TspTrack> util = new ExcelUtil<TspTrack>(TspTrack.class);
        util.exportExcel(response, list, "路由数据");
    }

    /**
     * 获取路由详细信息
     */
    @ApiOperation(value = "详细")
    @PreAuthorize("@ss.hasPermi('order:track:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(tspTrackService.selectTspTrackById(id));
    }

    /**
     * 新增路由
     */
    @ApiOperation(value = "新增")
    @PreAuthorize("@ss.hasPermi('order:track:add')")
    @Log(title = "路由", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TspTrack tspTrack) {
        return toAjax(tspTrackService.insertTspTrack(tspTrack));
    }

    /**
     * 修改路由
     */
    @ApiOperation(value = "编辑")
    @PreAuthorize("@ss.hasPermi('order:track:edit')")
    @Log(title = "路由", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TspTrack tspTrack) {
        return toAjax(tspTrackService.updateTspTrack(tspTrack));
    }

    /**
     * 删除路由
     */
    @ApiOperation(value = "删除")
    @PreAuthorize("@ss.hasPermi('order:track:remove')")
    @Log(title = "路由", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tspTrackService.deleteTspTrackByIds(ids));
    }
}
